<?php
session_start();
session_unset();
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>.: CARALUGUE - Locacão de Veículos</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/style.css"/>
        <script type="text/javascript" src="js/ajaxInit.js"></script>
        <script type="text/javascript">
            function carregar(){
                ajax = ajaxInit();

                var login = document.getElementById("login").value;
                var senha = document.getElementById("senha").value;
                
                if(ajax){
                    ajax.onreadystatechange = function()
                    {
                        if (ajax.readyState==4 && ajax.status==200)
                        {
                            if(ajax.responseText == 'autorizado'){
                                document.getElementById("formulario").submit();
                            } else {
                                alert('Usuário ou senha incorreto. Por favor, tente novamente.');
                            }
                        }
                    }
                    ajax.open("GET","http://localhost/caralugue/autenticacao.php?login="+login+"&pass="+senha+"",true);
                    ajax.send();
                }
            }
        </script>
    </head>
    <body>
        <div id="painel">
            <form id="formulario" name="formulario" action="home.php" method="POST">
                <span class="pequeno">Bem vindo ao site da</span> <span class="destaque"> CARALUGUE </span> <br /> 
                <span class="pequeno">Locacão de Veículos.</span>
                <div id="resultado" class="pequeno">

                </div>
                <div id="campos">
                    <table>
                        <tr>
                            <td>
                                <span class="negrito">Login</span> 
                            </td> 
                            <td>
                                <input type="text" id="login" name="login" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span class="negrito">Senha</span> 
                            </td>
                            <td>
                                <input type="password" id="senha" name="senha" />
                            </td>
                        </tr>
                    </table>
                    <br />
                    <input type="button" value="Entrar" onclick="carregar()"/>
                </div>
            </form>
        </div>
    </body>
</html>